package www.dianbaozu.com.ui.find.searchServer.adapter

import android.annotation.SuppressLint
import androidx.databinding.DataBindingUtil
import androidx.recyclerview.widget.RecyclerView
import com.netease.nim.uikit.common.ui.recyclerview.adapter.BaseQuickAdapter
import com.netease.nim.uikit.common.ui.recyclerview.holder.BaseViewHolder
import com.netease.nim.uikit.databinding.ItemSearchServerBinding
import www.dianbaozu.com.R
import www.wen.com.common.lib.data.entities.ServerEntity
import www.wen.com.common.lib.extension.glide.setImageUrl
import www.wen.com.common.lib.extension.imgUrl

class SearchServerAdapter(
    recyclerView: RecyclerView,
    layoutId: Int,
    data: List<ServerEntity>,
) :
    BaseQuickAdapter<ServerEntity, BaseViewHolder>(recyclerView, layoutId, data) {
    private var binding: ItemSearchServerBinding? = null

    @SuppressLint("SetTextI18n")
    override fun convert(
        helper: BaseViewHolder,
        item: ServerEntity,
        position: Int,
        isScrolling: Boolean
    ) {
        binding = DataBindingUtil.bind(helper.itemView)
        binding?.apply {
            strTelegramGroup.text = item.serverName
            tvIntroduction.text = item.serverIntro
            tvOnlineCount.text = "${item.onlineCount}人在线"
            setImageUrl(ivServerLogo, item.serverBackground.imgUrl(),R.drawable.image_default_list)
            setImageUrl(ivTelegramAvatar, item.serverLogo.imgUrl())
        }
    }
}